﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Core;

namespace DAL
{
    public class ReVoteDetailDAL : SyncBase<Model.ReVoteDetail>
    {
        static ReVoteDetailDAL()
        {
            StringBuilder strSql = new StringBuilder();
            ReVoteDetailDAL.addSQL = @"insert into TempReVoteDetail(
VoteID,VoteBatch,TeacherID,LessionID,StudentID,VoteType,FeedContent,RecordTime)
 values (
@VoteID,@VoteBatch,@TeacherID,@LessionID,@StudentID,@VoteType,@FeedContent,@RecordTime)";
            ReVoteDetailDAL.tbName = "TempReVoteDetail";
            ReVoteDetailDAL.remoteUrl = "/Ayyfford/AddReVoteDetail";
            ReVoteDetailDAL.setVal = (lt) =>
            {
                StringBuilder sb = new StringBuilder();
                string _ids = string.Empty;
                if (lt != null && lt.Count > 0)
                {
                    lt.ForEach(t =>
                    {
                        _ids += t.ID + ",";
                        sb.AppendFormat("({0}, {1}, {2}, {3}, {4}, {5}, {6},{7}),",
                                         t.VoteID.NullNumber(), t.VoteBatch.NullNumber(), t.TeacherID.NullNumber(), t.LessionID.NullNumber(), t.StudentID.NullNumber(), t.VoteType.NullNumber(), t.FeedContent.NullString(), t.RecordTime.NullDate());
                    });
                }
                return new Tuple<string, string>(sb.ToString(), _ids);
            };
        }

        new public static void SaveEntity(Model.ReVoteDetail t)
        {
            SyncBase<Model.ReVoteDetail>.SaveEntity(t);
        }

        new public static void AsyncData()
        {
            SyncBase<Model.ReVoteDetail>.AsyncData();
        }
    }
}
